
<?php
$j = 0;
foreach ($users as $user) {
    $id = $user['u1']['userID'];
    $options[$id] = $user['u1']['username'];
}
foreach ($users as $user) {

    if ($user['u1']['image'] == "") {
        $user['u1']['image'] = "http://localhost/default.png";
    }
    $id = $user['u1']['userID'];
    $usersWithImage[$id] = array('name' => $this->Html->image($user['u1']['image']) . $user['u1']['username'], 'id' => $id); //$this->Html->image($x['image']) . " " . $x['name'];
}
echo $this->Form->create('Task');
foreach ($usersWithImage as $userWithImage) {
    ?> <div class="checkbox"><input type="checkbox" name="data[Task][sentTo][]" value="<?php echo $userWithImage['id']; ?>" id ="TaskSentTo<?php echo $userWithImage['id']; ?>" /><label for="TaskSentTo<?php echo $userWithImage['id']; ?>"><?php echo $userWithImage['name']; ?></label></div>
    <br></br>
    <?php
}echo $this->Form->input('action', array('style' => 'width:500px', 'type' => 'hidden', 'value' => 'reassign'));
$selectedUsers = null;
if ($this->request->data != null) {
    $selectedUsers = $this->request->data['Task']['sentTo'];
}
$j = 0;
if ($selectedUsers != null) {
    foreach ($selectedUsers as $selectedUser) {
        echo "selected user = " . $selectedUser;
        $selectedUsers[$j] = $users[$selectedUser]['u1']['userID'];
        $j++;
    }
}

echo $this->Form->end('Reassign');



